package com.alawn.framework.services.system;

import com.alawn.framework.core.domain.BaseEntity;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableName;

import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 个人喜好设置表
 * </p>
 *
 * @author johnny
 * @since 2019-02-27
 */
@Getter
@Setter
@TableName("mz_a_preference")
public class Preference extends BaseEntity {

	private static final long serialVersionUID = 1L;

	/**
	 * 菜单模型
	 */
	private String menuMode = "layout-menu-static";;

	/**
	 * 主题
	 */
	private String theme = "indigo";

	/**
	 * 布局
	 */
	private String layout = "indigo";

	/**
	 * 是否亮色菜单
	 */
	private boolean lightMenu;

	/**
	 * 夜间模式
	 */
	private boolean nightMode = false;

	/**
	 * 菜单左右编号
	 */
	@TableField("orientation_RTL")
	private String orientationRTL;

	public String getMenuMode() {
		String mode = menuMode;
		if (this.isLightMenu()) {
			mode = mode + " layout-menu-light";
		}

		return mode;
	}

	public void changeTheme(String value) {
		if (this.isNightMode()) {
			this.theme = value + "-dark";
		} else {
			this.theme = value;
		}

		if (value.indexOf("-") != -1) {
			this.layout = value.split("-")[0];
		} else {
			this.layout = value;
		}
	}
}
